package weworkgo

import (
	"errors"
	"gitee.com/microrain/weworkgo/lib"
)

var messageSendUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="

//SendMsg 发送信息
func SendMsg(accessToken string, data interface{}) error {
	result, err := lib.HttpPostData(messageSendUrl+accessToken, data)
	if err != nil {
		return err
	}
	response := lib.UnJson(result, new(MessageSendResponse)).(*MessageSendResponse)
	if response == nil || response.Errcode > 0 {
		return errors.New("Request SendMsg Failed: " + result)
	}
	return nil
}
